﻿using UnityEngine;
using System.Collections;

public class CarrierWooble : MonoBehaviour {

	public float rotation = 1.0f;
	public float timeBetweenCycles = 1000.0f;
	public Vector3 rotationAxis = new Vector3(0.0f, 0.0f, 1.0f);

	private float timeSinceLastCycle = 0.0f;
	private enum state {
		UP,
		DOWN
	};
	state stateNow = state.UP;

	// Use this for initialization
	void Start () {
		timeSinceLastCycle = timeBetweenCycles / 2.0f;
	}
	
	// Update is called once per frame
	void Update () {
		timeSinceLastCycle -= Time.deltaTime;
		if (timeSinceLastCycle < 0) {
			stateNow = stateNow == state.UP ? state.DOWN : state.UP;
			timeSinceLastCycle = timeBetweenCycles;
		}

		transform.RotateAround(transform.position, rotationAxis, stateNow == state.UP ? rotation : -rotation);
	}
}
